package edu.mit.compilers.assembly.x64.basic;

import java.util.ArrayList;

public class X64ScaledMemOperand implements X64Operand {

    private X64Register base;
    private X64Register offset;
    private int scaled;

    public X64ScaledMemOperand(X64Register base, X64Register offset, int scaled) {
        this.base = base;
        this.offset = offset;
        this.scaled = scaled;
    }

    @Override
    public String getAddress() {
        return "(%" + base.name + ", %" + offset.name + ", " + scaled + ")";
    }

    @Override
    public Type getType() {
        return Type.MEM;
    }

    @Override
    public ArrayList<X64Register> getUsedRegisters() {
        ArrayList<X64Register> ret = new ArrayList<>();
        ret.add(base);
        ret.add(offset);
        return ret;
    }
}
